import {Component, OnInit} from '@angular/core';

@Component({
  selector: 'app-product',
  templateUrl: './product.component.html',
  styleUrls: ['./product.component.scss']
})
export class ProductComponent implements OnInit {

  private products: Array<Product>;
  private imgUrl: string;

  constructor() {
  }

  ngOnInit() {
    this.products = [
      new Product(1, '第一个商品', 0.01, 4.5, '我是商品介绍', ['数码产品']),
      new Product(1, '第一个商品', 0.01, 3.5, '我是商品介绍', ['数码产品']),
      new Product(1, '第一个商品', 0.01, 1.5, '我是商品介绍', ['数码产品']),
      new Product(1, '第一个商品', 0.01, 2.5, '我是商品介绍', ['数码产品']),
      new Product(1, '第一个商品', 0.01, 3.5, '我是商品介绍', ['数码产品']),
      new Product(1, '第一个商品', 0.01, 1.5, '我是商品介绍', ['数码产品'])
    ];
    this.imgUrl = 'http://placehold.it/320x150';
  }

}

export class Product {
  constructor(public id: number, public title: string, public price: number,
              public rating: number, public desc: string, public categories: Array<string>) {
  }
}
